package com.uinnova.visualbase.controller;

import com.uinnova.visualbase.dao.User;
import com.uinnova.visualbase.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class UserController {

@Autowired
public UserService userService;
    @ResponseBody
    @RequestMapping("/userLogin")
    public int userLogin(String username, String password, Model model, HttpSession session) {

        int flag = userService.testLogin(username,password);
        if(flag == 0){
            User user = userService.queryByUsername(username);
            session.setAttribute("userSession",user);
            System.out.println("我已经保存好了");
        }
        System.out.println("这次我是"+flag);
        return flag;
    }
}
